package GUI.Ventas;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class MainVentas extends Dialog {

	protected Object result;
	protected Shell shell;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public MainVentas(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), getStyle());
		shell.setSize(450, 300);
		shell.setText(getText());
		
		Label label = new Label(shell, SWT.NONE);
		label.setText("Seleccione La Opcion Deseada");
		label.setFont(SWTResourceManager.getFont("Lucida Grande", 13, SWT.NORMAL));
		label.setBounds(128, 33, 195, 17);
		
		Button button = new Button(shell, SWT.NONE);
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MostradorVentaDelivery m = new MostradorVentaDelivery (shell, shell.getStyle(), 0);
				//	shell.setVisible(false);
					m.open();
			}
		});
		button.setText("Ingresar Nueva Venta");
		button.setBounds(131, 77, 212, 28);
		
		Button button_1 = new Button(shell, SWT.NONE);
		button_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MostradorVentaDelivery m = new MostradorVentaDelivery(shell,shell.getStyle(),3);
				//shell.setVisible(false);
				m.open();
			}
		});
		button_1.setText("Agregar Ordenes a una Venta");
		button_1.setBounds(131, 122, 212, 28);
		
		Button button_2 = new Button(shell, SWT.NONE);
		button_2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MostradorVentaDelivery a  = new MostradorVentaDelivery (shell, shell.getStyle(), 1);
				//	shell.setVisible(false);
					a.open();
			}
		});
		button_2.setText("Ver Ventas Abiertas");
		button_2.setBounds(131, 168, 212, 28);
		
		Button button_3 = new Button(shell, SWT.NONE);
		button_3.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MostradorVentaDelivery a = new MostradorVentaDelivery(shell,shell.getStyle(),2);
				
				
				
				a.open();

			}
		});
		button_3.setText("Cerrar Venta");
		button_3.setBounds(131, 218, 212, 28);

	}

}
